<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>login登录页面</title>

    <!--引入Vue组件-->
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"></script>
    <!--引入Axios组件，用来发送异步http请求的-->
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

</head>
<body>

<div id="app">
    username:<input type="text" v-model="user.username"> <br>
    password:<input type="password" v-model="user.password"> <br>
    <button @click="login">登录</button>
</div>
<script>

    new Vue({
        el:"#app",
        data:{
            user:{
                username:"",
                password:""
            }
        },
        methods:{
            login(){
                axios({
                    method:"post",
                    url:"/login",
                    params:this.user
                }).then(resp=>{
                    location.href = "index.html";
                });
            }
        }
    })

</script>

</body>
